-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix updating the session history to activate new Documents #6199
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is ready for review. The one thing I don't like so much in this PR is that we handle document-replacement and whole-session-entry replacement differently. I feel like we could maybe simplify this in the future by just always replacing the entire entry and conditionally copying over the right state from the old entry depending on the handling mode. This is far from specific to this PR though as we've always had this quirk, so I think it's fine as-is here.
OK, the latest commit uses the history handling This allows us to do as little manual curating of what we pass into #traverse-the-history as possible while still keeping everything simple and correct. Users of #traverse-the-history just need to know which historyHandling value to pass in if they require something other than the default behavior (which is nothing), and they need to know what actions they should take when using their historyHandling value (that is they should know that Let me know if this works for you, otherwise I'm happy to discuss it more and maybe change directions. I'm just slightly partial to not introducing a new slightly-related concept that may require some "translation" for callers of #traverse-the-history. |
Proposed commit message:
|
LGTM! My only nit would be potentially elaborating on the paragraph:
... to include a little about what replacement actually does, but that's super picky and possibly already obvious, so I'm fine with whatever. |
Before this PR, the spec made new documents that landed in the #update-the-session-history-with-the-new-page algorithm, and if one of the first two condition branches of Step 3 were matched, these documents were never activated in #traverse-the-history.
After this PR, all new documents created that eventually land in the #update-the-session-history-with-the-new-page algorithm will actually be activated if necessary (set as the browsing context's active document) via #traverse-the-history.
This PR fixes #6197 by doing the following:
(Old proposal)
- [x] ~Changing the signature of #update-the-session-history-with-the-new-page to explicitly take a new Document~ - [x] ~Plumb the new document to all call sites of this algorithm~ - [x] ~Change the first conditional branch of #update-the-session-history-with-the-new-page > step 3 to create a new session history entry, explicitly put it in place of the **current entry**, and traverse the history to it~ - [x] ~Update the `"entry update"` history handling behavior dfn to more accurately reflect the current spec text~ - [x] ~Add a note explaining why we have both `"reload"` and `"replace"`, since they are very similar~ - ~If people think this is overkill let me know and I can nix it~ - [x] ~Change the second conditional branch of #update-the-session-history-with-the-new-page > step 3 to explicitly create a new entry that is put in place of the **current entry** in the session history, and traverse to _it_ instead of **current entry**~if (newDocument != current_entry.document)
, to...if (newDocument != current_entry.document || traverse-to-same-entry)
replace
history handling mode for #traverse-the-history (see my review for justification and mention of an alternative)replace
by creating a new entry and inserting it after current entry. This certainly seemed to be the spec's intention, but was never properly handledThe optional task from #6197 can be done as a follow-up:
active document
, and (b) Window's associated Document`, so that we can set a Window's associated Document ASAP, without setting the browsing context's active document./browsing-the-web.html ( diff )